{extend name="frame/base" /}
{block name="body"}
<form action="{$url}" method="post">
    <label>项目名称<input name="name" id="name" type="text" value="{$info['name']|default=''}"/>
    </label>
    <label>商家名称<input name="business" id="business" type="text" value="{$info['business']|default=''}"/>
    </label>
    <label>电话<input name="tel" id="tel" type="text" value="{$info['tel']|default=''}"/>
    </label>
    <label>到期时间<input name="endtime" id="endtime" type="text" class="some_class" value="{$info['endtime']|default=''}"/>
    </label>
    <label>用户名<input name="username" id="username" type="text" value="{$info['username']|default=''}"/>
    </label>
    <label>密码<input name="password" id="password" type="text" readonly value="{$info['password']|default=''}"/><div class="buttonlist"><button onclick="createpassword();return false;">随机生成</button></div>

    </label>
    <input type="submit" value="保存" onclick="submit_form();return false">
</form>
<br>
<script>
    $(function () {
        $.datetimepicker.setLocale('ch');
        $('.some_class').datetimepicker({
            formatTime:'H:i',
            format:'Y-m-d H:i'
        });
    })
    function submit_form() {
       var c=checkvar({"name":"项目名称不能为空","business":"商家名称不能为空","endtime":"结束时间不能为空","username":"用户名不能为空","password":"密码不能为空","tel":"电话不能为空"})
        if(c!=null){
           alert(c)
            return
        }
        $("form").submit()
    }
    function createpassword() {
        $("#password").val(randomString(8))
    }
    function randomString(len) {
        len = len || 32;
        var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
        var maxPos = $chars.length;
        var pwd = '';
        for (i = 0; i < len; i++) {
            pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
        }
        return pwd;
    }
</script>
{/block}
